﻿@model EOS.EntWebDemo.Models.Leave.LeaveView

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>请假申请页面</title>
    <link href="../../Content/jquery-easyui-1.5.2/themes/icon.css" rel="stylesheet" />
    <link href="../../Content/jquery-easyui-1.5.2/themes/default/easyui.css" rel="stylesheet" />

    <script src="../../Content/jquery-easyui-1.5.2/jquery.min.js"></script>
    <script src="../../Content/jquery-easyui-1.5.2/jquery.easyui.min.js"></script>
    <script src="../../Content/jquery-easyui-1.5.2/locale/easyui-lang-zh_CN.js"></script>

    <script type="text/javascript">
        function GetDateDiff(startTime, endTime, diffType) {
            //将xxxx-xx-xx的时间格式，转换为 xxxx/xx/xx的格式
            startTime = startTime.replace(/\-/g, "/");
            endTime = endTime.replace(/\-/g, "/");

            //将计算间隔类性字符转换为小写
            diffType = diffType.toLowerCase();
            var sTime = new Date(startTime);      //开始时间
            var eTime = new Date(endTime);  //结束时间
            //作为除数的数字
            var divNum = 1;
            switch (diffType) {
                case "second":
                    divNum = 1000;
                    break;
                case "minute":
                    divNum = 1000 * 60;
                    break;
                case "hour":
                    divNum = 1000 * 3600;
                    break;
                case "day":
                    divNum = 1000 * 3600 * 24;
                    break;
                default:
                    break;
            }
            return parseInt((eTime.getTime() - sTime.getTime()) / parseInt(divNum));
        }

        $(document).ready(function () {
            $("#ApproverName").change(function () {
                var ApproverID = $("#ApproverName").val();
                $('#ApproverID').val(ApproverID);
            })

            $("#StartTime").datetimebox({
                onChange: function () {
                    var StartTime = $("#StartTime").val();
                    var EndTime = $("#EndTime").val();
                    var LeaveTime = GetDateDiff(StartTime, EndTime, "hour");
                    alert(LeaveTime);

                    $('#LeaveTime').val(LeaveTime);
                }
            });

            $("#EndTime").change(function () {
                var ApproverID = $("#ApproverName").val();
                $('#ApproverID').val(ApproverID);

                if (StartTime <= EndTime) {

                }
            })
        })
    </script>

</head>
<body>
    @using (Html.BeginForm())
    {
        @Html.AntiForgeryToken()

        <div class="form-horizontal">
            @Html.ValidationSummary(true, "", new { @class = "text-danger" })
            <div class="form-group">
                @Html.LabelFor(model => model.LeaveType, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.DropDownList("LeaveType", ViewBag.leaveTypeList as IEnumerable<SelectListItem>, new { @class = "btn btn-success dropdown-toggle form-control" })
                    @Html.ValidationMessageFor(model => model.LeaveType, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @*@Html.LabelFor(model => model.ApplicantID, htmlAttributes: new { @class = "control-label col-md-2" })*@
                <div class="col-md-10">
                    @Html.HiddenFor(model => model.ApplicantID, new { htmlAttributes = new { @class = "form-control" } })
                    @*Html.ValidationMessageFor(model => model.ApplicantID, "", new { @class = "text-danger" })*@
                </div>
            </div>

            <div class="form-group">
                @*Html.LabelFor(model => model.ApproverID, htmlAttributes: new { @class = "control-label col-md-2" })*@
                <div class="col-md-10">
                    @Html.HiddenFor(model => model.ApproverID, new { htmlAttributes = new { @class = "form-control" } })
                    @*Html.ValidationMessageFor(model => model.ApproverID, "", new { @class = "text-danger" })*@
                </div>
            </div>
            @*申请者*@
            <div class="form-group">
                @Html.LabelFor(model => model.ApplicantName, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.TextBoxFor(model => model.ApplicantName, new { @class = "easyui-textbox", @data_options = "readonly : 'true'" })
                    @Html.ValidationMessageFor(model => model.ApplicantName, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.ApproverName, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @*Html.EditorFor(model => model.ApproverName, new { htmlAttributes = new { @class = "form-control" } })*@
                    @Html.DropDownList("ApproverName", ViewBag.approverList as IEnumerable<SelectListItem>, new { @class = "btn btn-success dropdown-toggle form-control" })
                    @Html.ValidationMessageFor(model => model.ApproverName, "", new { @class = "text-danger" })
                </div>
            </div>

            @*请假时间小计*@
            <div class="form-group">
                @Html.LabelFor(model => model.LeaveTime, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.TextBoxFor(model => model.LeaveTime, new { @class = "easyui-textbox", @data_options = "editable : 'false'" })
                    @Html.ValidationMessageFor(model => model.LeaveTime, "", new { @class = "text-danger" })
                </div>
            </div>

            @*开始时间*@
            <div class="form-group">
                @Html.LabelFor(model => model.StartTime, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.TextBoxFor(model => model.StartTime, htmlAttributes: new { @class = "easyui-datetimebox" })
                    @Html.ValidationMessageFor(model => model.StartTime, "", new { @class = "text-danger" })
                </div>
            </div>
            @*结束时间*@
            <div class="form-group">
                @Html.LabelFor(model => model.EndTime, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.TextBoxFor(model => model.EndTime, htmlAttributes: new { @class = "easyui-datetimebox" })
                    @Html.ValidationMessageFor(model => model.EndTime, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Reason, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Reason, new { htmlAttributes = new { @class = "easyui-validatebox", @data_options = "required:true,validType:'length[1,11]'" } })
                    @Html.ValidationMessageFor(model => model.Reason, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @*Html.LabelFor(model => model.Status, htmlAttributes: new { @class = "control-label col-md-2" })*@
                <div class="col-md-10">
                    @Html.HiddenFor(model => model.Status, new { htmlAttributes = new { @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.Status, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-offset-2 col-md-10">
                    <input type="submit" value="提交" class="btn btn-default" />
                </div>
            </div>
        </div>
    }

    <div>
        @Html.ActionLink("Back to List", "Index")
    </div>
</body>
</html>
